package javafx.officialdemo.Checkbox;

import javafx.scene.control.CheckBox;

/**
 * 复选框
 */
public class Checkbox {
	/**
	 * 构造器
	 * 
	 * A checkbox without a caption
	 * CheckBox cb1 = new CheckBox();
	 * 
	 * A checkbox with a string caption
	 * CheckBox cb2 = new CheckBox("Second");
	 * 
	 * 设置  信息 与 是否选中
	 * cb1.setText("First");
	 * cb1.setSelected(true);
	 */
	
	public void test(){
		CheckBox cb1 = new CheckBox();
		cb1.setIndeterminate(true);
	}
	
	/**
	 * 增加事件   demo
	 * 
		final String[] names = new String[]{"Security", "Project", "Chart"};
		final Image[] images = new Image[names.length];
		final ImageView[] icons = new ImageView[names.length];
		final CheckBox[] cbs = new CheckBox[names.length];
		
		for (int i = 0; i < names.length; i++) {
		    final Image image = images[i] =
		        new Image(getClass().getResourceAsStream(names[i] + ".png"));
		    final ImageView icon = icons[i] = new ImageView();
		    final CheckBox cb = cbs[i] = new CheckBox(names[i]);
		    cb.selectedProperty().addListener(
		        (ObservableValue<? extends Boolean> ov,
		            Boolean old_val, Boolean new_val) -> {
		                icon.setImage(new_val ? image : null);                
		    });
		}
	 */
}
